# Maintainer: Jan de Groot <jgc@archlinux.org>
# Maintainer: Zach Bacon <11doctorwhocanada@gmail.com>

_realname=libnotify
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.7.12
pkgrel=2
pkgdesc="Desktop notification library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://developer.gnome.org/notification-spec/"
license=('spdx:LGPL-2.1')
depends=("${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-glib2")
makedepends=("${MINGW_PACKAGE_PREFIX}-gtk3"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-libxslt"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz"
        "test-fix.patch"
        "fix-gtk-doc.patch"
        "fix-realpath.patch")
sha256sums=('744b2b37508135f8261b755a9debe6e09add421adc75bde930f6e198b70ab46e'
            '185e7885512106172627525a4ec1fc18c2f95844f733e49cece325874a55f8e6'
            '690f8bd32e6aa4828bc93d2d9a8cba4870c96fa7af248a64f8ab505d8389af4d'
            'a8aedb1659b3e414b31d75bcc36279e4b688db1185c619ec5680a1fa5c6c89d9')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  patch -p1 -i "${srcdir}/test-fix.patch"
  patch -p1 -i "${srcdir}/fix-gtk-doc.patch"
  patch -p1 -i "${srcdir}/fix-realpath.patch"
}

build() {
  [[ -d "${srcdir}"/build-${MSYSTEM} ]] && rm -rf "${srcdir}"/build-${MSYSTEM}
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/meson.exe \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --default-library=both \
      --buildtype=plain \
      -Dtests=false \
      -Dintrospection=enabled \
      -Dman=true \
      -Dgtk_doc=true \
      -Ddocbook_docs=disabled \
      "../${_realname}-${pkgver}"

  ${MINGW_PREFIX}/bin/meson.exe compile
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/meson.exe install --destdir="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
